package test3;

public class girlFriendTest {
    public static void main(String[] args){
        girlFriend[] arr=new girlFriend[4];
        girlFriend p1 = new  girlFriend("小美",18,"女","听音乐");
        girlFriend p2 = new  girlFriend("小丽",24,"女","弹吉他");
        girlFriend p3 = new  girlFriend("小爱",20,"女","看书");
        girlFriend p4 = new  girlFriend("小芳",28,"女","打游戏");
        arr[0]=p1;
        arr[1]=p2;
        arr[2]=p3;
        arr[3]=p4;
        int sum=0;
        girlFriend age;
        for(int i=0;i<4;i++){
            age=arr[i];
            sum+= age.getAge();
        }
        double avg=sum/4.0;
        System.out.println("女朋友们年龄的平均数数为"+avg);

        int counts=0;
        for(int i=0;i<4;i++){
            age=arr[i];
            if(age.getAge()<avg) {
                counts++;
                if(counts==1){
                    System.out.println("年龄比年龄平均值小的女朋友信息有：");
                }
                System.out.println("姓名："+age.getName());
                System.out.println("年龄："+age.getAge());
                System.out.println("性别："+age.getGender());
                System.out.println("爱好："+age.getLike());
            }
        }
    }
}
